<!-- news -->
<script setup>
import { reactive, ref } from "vue";
import { NSpace, NSkeleton } from 'naive-ui'
import { useLazyData } from '@/utils'
import Pannel from "@/components/home/home-panel.vue";
import More from "@/components/more.vue";
import { findNews } from '@/api/home';

const homeNew = ref(null)
const targetIsVisible = ref(false)

let goods = useLazyData(homeNew, findNews)

</script>

<template>
  <Transition>
    <div ref="homeNew" class="flex-around" v-if="goods.length <= 0" style="margin: 30px 0px;">
      <n-space vertical v-for="i in 4" :key="i">
        <n-skeleton height="306px" width="306px" :sharp="false" />
        <n-skeleton height="30px" width="306px" />
        <n-skeleton height="30px" width="306px" />
      </n-space>
    </div>
    <div class="home-new" v-else>
      <Pannel title="新鲜好物" subTitle="新鲜出炉 品质靠谱">
        <template #right>
          <More path="/"></More>
        </template>
        <!-- 面板内容 -->
        <ul class="goods-list">
          <li v-for="item in goods" :key="item.id">
            <RouterLink :to="`/product/${item.id}`">
              <img v-lazy="item.picture" alt />
              <p class="name ellipse">{{ item.name }}</p>
              <p class="price">&yen;{{ item.price }}</p>
            </RouterLink>
          </li>
        </ul>
      </Pannel>
    </div>
  </Transition>
</template>

<style lang="less" scoped>
.goods-list {
  display: flex;
  justify-content: space-between;
  li {
    width: 306px;
    height: 390px;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    .name,
    .price {
      font-size: 14px;
      font-family: "Microsoft Yahei", "微软雅黑", verdana;
      padding: 0px 30px 0 30px;
      text-align: center;
    }
    .name {
      padding-top: 15px;
      font-weight: bold;
    }
    .price {
      padding-top: 5px;
      color: @priceColor;
    }

    &:hover {
      background-color: #dffff8;
    }
  }
}
</style>
